package utils

import java.io.File

import play.api.libs.json.Json

import scala.util.parsing.json.JSON

object Utils {

  def jsonToMap(json:String) = {
    JSON.parseFull(json).get.asInstanceOf[Map[String, String]]
  }

  def jsonToMapSeq(json:String) = {
    JSON.parseFull(json).get.asInstanceOf[Seq[Map[String, String]]]
  }

  def jsonToMapDouble(json:String) = {
    JSON.parseFull(json).get.asInstanceOf[Map[String, Double]]
  }

  def mapToJson(map:Map[String,String]) = {
    Json.toJson(map).toString()
  }

  def stringToJson(map:String) = {
    Json.toJson(map).toString()
  }


  val isWindow: Boolean = {
    System.getProperties.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1
  }

  val windowsPath = "I:/exosome_database"
  val linuxPath: String = new File("../").getAbsolutePath
  val path: String = {
    if (isWindow) windowsPath else linuxPath
  }


}
